import {createRouter, createWebHashHistory} from "vue-router";
import Home from "../views/Home.vue";

const routes = [
    {
        path: '/',
        redirect: '/blog'  // 修改重定向路径为小写 '/home' 保持一致性
    },
    {
        path: "/home",  // 路径改为小写，保持一致性
        name: "Home",   // 名称保持大写开头（符合Vue命名规范）
        children: [
            {
                path: "/blog",
                name: "Blog",
                component: () => import(/* webpackChunkName: "blog" */ "../views/Scholarship.vue"),
                meta: {
                    title: '主页'
                }
            },
            {
                path: "/login",
                name: "Login",
                component: () => import(/* webpackChunkName: "login" */ "../views/Login.vue"),
                meta: {
                    title: '登录'
                }
            },
            {
                path: "/register",
                name: "Register",
                component: () => import(/* webpackChunkName: "register" */ "../views/Register.vue"),
                meta: {
                    title: '注册'
                }
            }
        ],
        component: () => import(/* webpackChunkName: "home" */ "../views/Home.vue"),  // 修正组件路径和webpackChunkName
        meta: {
            title: '首页'  // 可选的元信息
        }

    },

];

const router = createRouter({
    history: createWebHashHistory(),
    routes
});

router.beforeEach((to, from, next) => {
    document.title = `研究生奖学金评选系统`;
    next()
});

export default router;
